package org.xbzheng.jpa.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xbzheng.jpa.bean.User;
import org.xbzheng.jpa.dao.UserRepository;

import java.util.List;
import java.util.Optional;

/**
 * Created by xbzheng on 2018/7/10.
 */
@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;

    public List<User> findUser(String username){
        Optional<List<User>> byUsername = userRepository.findByUsername(username);
        if (byUsername.isPresent()){
            return byUsername.get();
        }
        return null;
    }
}
